package net.bwie.jtp.dws.log.funcion;

import net.bwie.jtp.dws.log.bean.PageViewBean;
import org.apache.flink.api.common.functions.ReduceFunction;

// TODO: 2025/5/20 优化
/*
   创建ReducFunction函数实例,对每分钟窗口中的数据进增量计算
   ReducFunction函数要求聚合结果类型,必须与 窗口中的一致
 */
public class PageViewReportReduceFunction implements ReduceFunction<PageViewBean> {
    // TODO: 2025/5/20 value1表示增加计算中间结果;value2表示窗口中的每条数据 
    @Override
    public PageViewBean reduce(PageViewBean value1, PageViewBean value2) throws Exception {
        // TODO: 2025/5/20 增量计算:各个指标值相加
        value1.setPvCount(value1.getPvCount()+value2.getPvCount());
        value1.setPvDuringTime(value1.getPvDuringTime()+value2.getPvDuringTime());
        value1.setUvCount(value1.getUvCount()+value2.getUvCount());
        value1.setSessionCount(value1.getSessionCount()+value2.getSessionCount());
        // TODO: 2025/5/20 返回结果 
        return value1;
    }
}
